package com.ray.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

import com.mchange.v1.util.StringTokenizerUtils;
import com.ray.service.BasicDataService;

/**
 * 创建各种Id的工具类
* <p>Title: CreateIdUtil</p>  
* <p>Description: </p>   
* @author 李斌  
* @date 2018年4月14日
 */
@SuppressWarnings("unused")
public class CreateIdUtil {
	
	
	
	public final static String PURCHASE_ID_MAIN="采购主";
	
	public final static String PURCHASE_ID_DETAIL = "采购明细";
	
	public final static String WAREHOUSE_OUT = "出库";
	
	public final static String WAREHOUSE_IN = "入库";
	
	public final static String FEED_ID_MAIN = "投料主";
	
	public final static String FEED_ID_DETAIL = "投料明细";
	
	public final static String PAYMENT = "FK";
	
	public final static String RECEIPT = "SK";
	
	
	
	//生成id方法 
	public final static String getId(String orderType) { 
		String startWith = BasicDataService.getPYIndexStr(orderType, true);
		String endWith = (System.nanoTime()+"").substring(8, 12);
		String end = new Random().nextInt(10000)+"";
		String id = startWith+StringUtil.getUUID().substring(0, 17)+endWith+end;
		return id;  
	} 
	 
	public static void main(String[] args) {
		A a = new A();
		new Thread(a).start();
		A b = new A();
		new Thread(b).start(); 
	
		 
	}
	
}
class A implements Runnable{

	@Override
	public void run() {
		for(int i = 0;i<1000;i++) { 
			System.out.println(CreateIdUtil.getId(CreateIdUtil.WAREHOUSE_IN)); 
		}
	}
	
}
